using System;
using Headsight.BPMN2WF.BPMN.Model;
using Headsight.BPMN2WF.BPMN.Schemas;

namespace Headsight.BPMN2WF.Testing.TestObjCtors
{
    /// <summary>
    /// <see cref="BPMNSequenceFlow"/> <see cref="ITestObjCtor{T}"/>.
    /// </summary>
    public class BPMNSequenceFlowCtor : ITestObjCtor<BPMNSequenceFlow>
    {
        private String _id;
        private tFlowNode _tFlowNodeTarget;
        private tFlowNode _tFlowNodeSource;

        public BPMNSequenceFlow Create()
        {
            var result = new BPMNSequenceFlow(new tSequenceFlowCtor().WithId(_id).Create());

            result.TElement.sourceRef = (_tFlowNodeSource != null) ? _tFlowNodeSource.id : null;
            result.TElement.targetRef = (_tFlowNodeTarget != null) ? _tFlowNodeTarget.id : null;

            return result;
        }

        public BPMNSequenceFlowCtor WithId(String id)
        {
            _id = id;

            return this;
        }

        public BPMNSequenceFlowCtor WithFlowTo(tFlowNode tFlowNodeTarget)
        {
            _tFlowNodeTarget = tFlowNodeTarget;

            return this;
        }

        public BPMNSequenceFlowCtor WithFlowFrom(tFlowNode tFlowNodeSource)
        {
            _tFlowNodeSource = tFlowNodeSource;

            return this;
        }
    }
}